#include "base_server.cpp"

//一个客户端一个子进程client

int main(){
    int sockfd, portno, n;
    struct sockaddr_in serv_addr;
    struct hostent *server;

    char buffer[256];
    //test data
    portno = 9010;
    //test end

    //创建socket
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if(sockfd < 0){
        error_func("create socket失败", sockfd);
    }

    //准备connect
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    serv_addr.sin_port = htons(portno);
    if(::connect(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0){
        error_func("connect socket失败");
    }

    n = read(sockfd, buffer, 255);
    if(n < 0){
        error_func("read socket失败", n);
    }else if(n == 0){
        error_func("read socket为空", n);
    }

   

    close(sockfd);

    std::cout<<"heheeh"<<std::endl;
}